<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="<?php echo site_url('static/style/js/jquery.js');?>"></script>
<script type="text/javascript" src="<?php echo site_url('static/style/js/dialog.js');?>"></script>
<link href="<?php echo site_url('static/style/css/dialog.css');?>" rel="stylesheet" type="text/css" />
<title>抽奖管理后台</title>

<style>
body{background:#F4F4FF; font-size:14px; margin:auto}
.divScroll{     OVERFLOW:auto;
        scrollbar-face-color: #FFFFFF;
        scrollbar-shadow-color: #D2E5F4;
        scrollbar-highlight-color: #D2E5F4;
        scrollbar-3dlight-color: #FFFFFF;
        scrollbar-darkshadow-color: #FFFFFF;
        scrollbar-track-color: #FFFFFF; 
      scrollbar-arrow-color: #D2E5F4;
	  }
</style>
<script type="text/javascript">
var div = '';

	function openwin(url)
	{
		window.location=''+url+'';
	}

	function addstock(id)
	{
		$("#productid").val(id);
		//$("#cardnum").val('123123123');
		 dialog("我的标题","id:pop","300px","auto","id");
		 div = $("#pop").html();
		 $("#pop").html('');
	}

	//关闭POP
	function closepop(tar)
	{
		$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
		$("#floatBox").css({display:"none"});
		var id = '#'+tar;
		$(id).html(div);
	}

	function submitp()
	{
		var cardnum   = $("#cardnum").val();
		var productid = $("#productid").val();
		if(cardnum !='' && productid !=''){
			
			$.post("stock/addstock",{cardnum:cardnum, productid:productid},function(result){
				if(result > 0){
					closepop('pop');
					location.reload();
				}else{
					alert('发生错误，请重试');
					closepop('pop');
				}
				
			});
			
		}

	}

	function delstock(id)
	{
		if(id !=''){
			
			$.post("stock/delstock",{id:id},function(result){
				if(result > 0){
					//closepop('pop');
					location.reload();
				}else{
					alert('发生错误，请重试');
					//closepop('pop');
				}
				
			});
			
		}
	}
		
</script>
</head>

<body topmargin="0">
<div id="pop" style="display:none">
<form name="form1"> 
	<table width="333" border="0" cellpadding="0">
	  <tr>
	    <td width="329" height="23">添加属性</td>
	  </tr>
	  <tr>
	    <td height="61" align="center">
	     	<input type="hidden" name="productid"  id="productid"/>
	        <input type="text" name="cardnum" value="" id="cardnum" />
	
	    </td>
	  </tr>
	  <tr>
	    <td height="26" align="center">
	        <input type="button" name="button" id="button" value="添加" onclick="submitp();"/>
	        <input type="button" value="取消" onclick="closepop('pop');" />
	    </td>
	  </tr>
	</table>
</form>
</div>
<table width="1000px" border="0" cellpadding="0" bgcolor="#F4F4FF">
  <tr>
    <td width="235" height="37">&nbsp;</td>
    <td width="759">&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td>
        <input type="button" value="添加奖品"  onclick="window.location='<?php echo base_url('adminroot/product/addproduct');?>'"/>
    </td>
  </tr>
  <tr>
    <td height="485" align="center" valign="top">
<?php require_once 'left.php';?>
    </td>
    <td valign="top" align="center">
	<div align="center" style="width: 90%px; height: 500px; background:#FFFFFF;border:#999999; border:solid;border-width:1px;" class="divScroll">
		 <table width="100%" border="0" cellpadding="0">
		  <?php foreach($list as $key => $value){ ?>
          <tr onMouseMove="javascript:this.bgColor='#FCFDEE';"
		onMouseOut="javascript:this.bgColor='#FFFFFF';">
            <td width="100%">
           <table width="100%" border="0" cellpadding="0">
          <tr>
            <td width="131" height="22"><font color="#FF0000">奖品名称:</font></td>
            <td width="833" align="left"><?=$value['productname']?></td>
            <td width="259" rowspan="4">
                <input type="button" name="button" id="button" value="编辑" onclick="window.location='<?php echo site_url('adminroot/product/edit_product/id/'.$value['id']);?>'"/>
                 <input type="button" name="button" id="button" value="删除" onclick="window.location='<?php echo site_url('adminroot/product/del_product/id/'.$value['id']);?>'"/>                 </td>
          </tr>
          <tr>
            <td height="22"><font color="#FF0000">奖品详情:</font></td>
            <td align="left"><?=$value['content']?></td>
            </tr>
          <tr>
            <td height="24"><font color="#FF0000">奖品属性:</font></td>
            <td align="left"><?=getproducttype($value['ptype'])?></td>
            </tr>
          <tr>
            <td height="25"><font color="#FF0000">奖品属性:</font></td>
            <td align="left">
            <input type="button" value="添加" onclick="addstock('<?=$value['id']?>');" />            </td>
            </tr>

          <tr>
            <td height="25"></td>
            <td align="left">
                        <?php 
            	if (!empty($stock[$value['id']])){
            		foreach($stock[$value['id']] as $k => $v){
            			if( empty($v['rewardid'])){
            			
            ?>
           <li> <?=$v['cardnum']?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:delstock('<?=$v['id']?>');">删除</a></li>
                      <?php 
            			}
            		}
            	}
          ?>            </td>
            <td>&nbsp;</td>
          </tr>

           <tr>
            <td height="25" colspan="3"><hr/></td>
            </tr>
        </table>
            </td>
          </tr>
          <?php } ?>          

                    

                    
        </table>
	<div>
    
    </td>
  </tr>
</table>
</body>
</html>
